﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Synchronization;

namespace Obra.Sync
{
    public class MediaItemMetadata
    {
        public MediaItemMetadata()
        {
        }

        /// <summary>
        /// The name of the media file.
        /// </summary>
        /// <remarks>
        /// <para>
        /// The name is the full name of the media file, and includes the album
        /// and file name separated by a forward slash (/).
        /// </para>
        /// </remarks>
        public string Name
        {
            get;
            set;
        }

        /// <summary>
        /// Forward slash separates an album and media component of the 
        /// canonical name.
        /// </summary>
        private readonly static char[] Seperator = new char[] { '/' };


        /// <summary>
        /// The album of this SyncItem.
        /// </summary>
        public string AlbumName
        {
            get { return this.Name.Split(MediaItemMetadata.Seperator)[0]; }
        }

        /// <summary>
        /// The media name of this SyncItem.
        /// </summary>
        public string MediaName
        {
            get { return this.Name.Split(MediaItemMetadata.Seperator)[1]; }
        }


        /// <summary>
        /// Checksum of the media file.
        /// </summary>
        /// <remarks>
        /// <para>
        /// The checksum algorithm is implementation dependent.  SmugMug uses
        /// MD5 for example.
        /// </para>
        /// </remarks>
        public string Checksum
        {
            get;
            set;
        }

        /// <summary>
        /// Timestamp of when this media item was last modified.
        /// </summary>
        /// <remarks>
        /// <para>
        /// This value is expressed in ticks, and is based on the UTC timezone.
        /// </para>
        /// </remarks>
        public ulong LastModifiedUtc
        {
            get;
            set;
        }

        /// <summary>
        /// Get the SyncId for this item.
        /// </summary>
        /// <remarks>
        /// <para>
        /// The SyncId is simply the (canonical) name of the media file.
        /// </para>
        /// </remarks>
        public SyncId SyncId
        {
            get { return new SyncId(this.Name); }
        }
    }
}
